package cn.hadron.ssh.service.impl;
import cn.hadron.ssh.bean.User;
import cn.hadron.ssh.dao.UserDao;
import cn.hadron.ssh.service.UserService;
public class UserServiceImpl implements UserService{
	private UserDao udao;

	@Override
	public void regist(User user) {  
        udao.save(user);  
    } 
	@Override
    public User find(Integer id){
    	return udao.load(id);
    }
	@Override
    public boolean find(String username){
		if(null!=udao.findUser(username))
    		return true;
		return false;
    }
	@Override
    public User login(String username,String password){
		User u=udao.findUser(username,password);
		if(u!=null)return u;
		return null;
    }
	@Override
    public void changePassword(Integer id,String password){
		User u=udao.load(id);
		u.setPassword(password);
		udao.update(u);
	}
	
	public UserDao getUdao() {
		return udao;
	}
	//Setter注入
	public void setUdao(UserDao udao) {
		this.udao = udao;
	}
}
